/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dao;

import helper.NewHibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import pojo.AddHistory;
import pojo.StoreHistory;

/**
 *
 * @author QTuan
 */
public class DAOStoreHistory {
    private Session session;
    public DAOStoreHistory()
    {
        SessionFactory factory = NewHibernateUtil.getSessionFactory();
        this.session = factory.getCurrentSession();
    }
    public boolean setStoreHistory(StoreHistory storehistory)
    {
         try
        {
            session.getTransaction().begin();
            session.save(storehistory);
            session.flush();
            session.getTransaction().commit();
            return true;
        }catch(Exception e)
        {
            if(session.getTransaction().isActive())
            {
                session.getTransaction().rollback();
            }
            e.printStackTrace();
        }
        return false;
    }
}
